package theone.ui;

import org.newdawn.slick.Color;
import org.newdawn.slick.Font;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.Image;

public class UiCheckbox extends UiComponent {
	
	private String text;
	private Font font;
	private boolean checked;
	private Image checker_on;
	private Image checker_off;
	
	public UiCheckbox(boolean p_checked, Image p_checker_on, Image p_checker_off, Font font_text) {
		checked = p_checked;
		checker_on = p_checker_on;
		checker_off = p_checker_off;
		font = font_text;
		
		text = "DEFAULT";
	}
	
	
	public void draw(Graphics g, int offsetX, int offsetY) {
		
		Color currentColor = Faded;
		if (isHover())
		{
			currentColor = Bright;
		}
		
		// Draw background
		if (checked)
			g.drawImage(checker_on, offsetX + getX(), offsetY + getY(), currentColor);
		else
			g.drawImage(checker_off, offsetX + getX(), offsetY + getY(), currentColor);
			
		
		// Draw text
		g.setFont(font);
		g.setColor(currentColor);
		g.drawString(text, offsetX + getX() + ((getWidth() - (checker_on.getWidth() + 5) - font.getWidth(text))/2) + checker_on.getWidth() + 5, 
				offsetY + getY() + ((getHeight() - font.getHeight(text))/2));
		
	}

}
